package com.inossem.warehousestorage_inossem.activity.inventory;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.inossem.loadandrefresh.pullableview.PullableListView;
import com.inossem.utils.listener.NoDoubleClickListener;
import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.activity.base.BaseActivity;
import com.inossem.warehousestorage_inossem.adapter.inventory.InventorySelectSpecialInvFlagAdapter;
import com.inossem.warehousestorage_inossem.bean.inventory.InventoryAreaBean;
import com.inossem.warehousestorage_inossem.bean.inventory.InventorySpeInvFlagListBean;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.request.inventory.InventoryManageRequest;
import com.inossem.warehousestorage_inossem.utils.ActivityUtils;

/**
 * Created by Administrator on 2017/9/2 0002.
 */

public class InventorySelectSpecialInvFlagActivity extends BaseActivity {

   private TextView title;


    private PullableListView list;

    private InventorySelectSpecialInvFlagAdapter adapter;


    private InventoryAreaBean areaBean;


    @Override
    protected void onCreateImpl(Bundle savedInstanceState) {
        setContentView(R.layout.activity_inventory_select);
        initView(this);
    }

    @Override
    protected void onResumeImpl() {
        initData(this);
    }

    private void initView(Activity activity) {
        title = (TextView) activity.findViewById(R.id.headerTitle);
        list = (PullableListView) activity.findViewById(R.id.list);
    }

    private void initData(Activity activity) {
        title.setText(activity.getResources().getString(R.string.activity_inventory_select_sp_flag_title));
        ActivityUtils.initBackAndFunction(activity, activity.getResources().getString(R.string.activity_inventory_item_title), new NoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                finish();
            }
        });

        list.setPullUpFlag(false);
        list.setPullDownFlag(false);
        adapter = new InventorySelectSpecialInvFlagAdapter(activity);
        list.setAdapter(adapter);
        getData(activity);
    }

    private void getData(Activity activity) {
        InventoryManageRequest.findSpeInvFlag(activity, new GsonBeanListener<InventorySpeInvFlagListBean>() {
            @Override
            public void onSuccess(InventorySpeInvFlagListBean bean) {
                adapter.setList( bean.getBody());
                adapter.notifyDataSetChanged();
            }
        });
    }





}
